package kg.aibek.projecteuler.p10;

import java.util.HashSet;
import java.util.Set;

public class Problem47 {
	public void solve() {
		int res = 0;
		for (int i = 644; i < Integer.MAX_VALUE; i++) {
			if (factorCount(i) == 4) {
				res++;
			} else {
				res = 0;
			}
			if (res == 4) {
				System.out.println(i);
				break;
			}
		}
	}

	private int factorCount(int number) {
		Set<Integer> set = factors(number);
		return set.size();
	}

	private Set<Integer> factors(int number) {
		Set<Integer> set = new HashSet<Integer>();

		for (int i = 2; i * i <= number; i++) {
			if (number % i == 0) {
				set.add(i);
				set.addAll(factors(number / i));
				return set;
			}
		}
		set.add(number);
		return set;
	}

	public static void main(String[] args) {
		Problem47 p = new Problem47();
		p.solve();
	}
}
